/**
 * @param {number[][]} plants
 * @param {number} target
 * @return {boolean}
 */
var findTargetIn2DPlants = function(plants, target) {
    if(plants.length===0) return false
    let x=plants[0].length-1,y=0
    while(x>=0&&y<plants.length){
        if(plants[y][x]>target)x-=1
        else if(plants[y][x]<target)y+=1
        else return true
    }
    return false
};
const plants = [[2,3,6,8],[4,5,8,9],[5,9,10,12]], target = 8
console.log(findTargetIn2DPlants(plants,target));